require(['./config'], () => {
    require(['template', 'header', 'footer2', 'leader'], (template) => {
        class List {
            constructor() {
                this.getData().then(() => {
                    this.addFun()
                })
            }
            getData() {
                return new Promise((resolve, reject) => {
                    let id = location.search.slice(location.search.indexOf("=") + 1)
                    $.ajax({
                        type: "get",
                        url: "/api/tab/2" + id,
                        data: "start = 0 ",
                        dataType: "json",
                        success: function(resp) {
                            let html = template("goods-list-template", {
                                data: resp.data.items.list
                            })
                            $(".goods-list").html(html)
                            let html2 = template('order-template', {
                                data: resp.data.sortTypes
                            })
                            $(".order-form").html(html2)
                            let html3 = template("add-listbox-template", {
                                data: resp.data.categories
                            })
                            $(".add-list").html(html3)
                            let html4 = template("list-itemadd-template", {
                                data: resp.data.sortTypes
                            })
                            $(".list-itme").html(html4)
                            resolve()
                        }
                    })
                })
            }
            addFun() {
                $(".list-icon").on("click", function() {
                    console.log($(this).parents()[1]);
                    $($(this).parents()[1]).toggleClass("close")

                })
            }

        }
        new List();
    })
})